﻿using BankSystemWithCSharp.UserPanel.FuncSubpanel;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace BankSystemWithCSharp
{
    public partial class FuncPanel : UserControl
    {
        private ShowMoneyPanel showMoneyPanel = new ShowMoneyPanel();
        private GetMoneyPanel getMoneyPanel = new GetMoneyPanel();
        private SaveMoneyPanel saveMoneyPanel = new SaveMoneyPanel();
        private SendMoneyPanel sendMoneyPanel = new SendMoneyPanel();
        private RecordPanel recordPanel = new RecordPanel();
        private Action Logout;
        private delegate void RefreshHandler();
        private event RefreshHandler refreshHandler;
        public FuncPanel(Action logout)
        {
            InitializeComponent();
            Logout = logout;

            showMoneyPanel.Dock = DockStyle.Fill;
            getMoneyPanel.Dock = DockStyle.Fill;
            saveMoneyPanel.Dock = DockStyle.Fill;
            sendMoneyPanel.Dock = DockStyle.Fill;
            recordPanel.Dock = DockStyle.Fill;

            refreshHandler += showMoneyPanel.HideMoney;
            refreshHandler += getMoneyPanel.Clear;
            refreshHandler += saveMoneyPanel.Clear;
            refreshHandler += sendMoneyPanel.Clear;
            refreshHandler += recordPanel.RefreshRecord;
        }

        private void showMoneyButton_Click(object sender, EventArgs e)
        {
            refreshHandler();
            panel1.Controls.Clear();
            panel1.Controls.Add(showMoneyPanel);
        }

        private void getMoneyButton_Click(object sender, EventArgs e)
        {
            refreshHandler();
            panel1.Controls.Clear();
            panel1.Controls.Add(getMoneyPanel);
        }

        private void saveMoneyButton_Click(object sender, EventArgs e)
        {
            refreshHandler();
            panel1.Controls.Clear();
            panel1.Controls.Add(saveMoneyPanel);
        }

        private void sendMoneyButton_Click(object sender, EventArgs e)
        {
            refreshHandler();
            panel1.Controls.Clear();
            panel1.Controls.Add(sendMoneyPanel);
        }

        private void logoutButton_Click(object sender, EventArgs e)
        {
            refreshHandler();
            panel1.Controls.Clear();
            Logout();
        }

        private void recordButton_Click(object sender, EventArgs e)
        {
            refreshHandler();
            panel1.Controls.Clear();
            panel1.Controls.Add(recordPanel);
        }
    }
}
